
$('.timer-ul').on("click", "li", function () {
    let contentId = $(this).attr('data-newsId');
    $(this).addClass('active').siblings().removeClass('active');
    $('.nav-list li').eq(1).text($(this).find('.year-describe').text())

    return newsController.createNewsTabContent(contentId);
})


$('.about-l-step').hover(function () {
    $('.scroll-bar').fadeIn('400');
}, function () {
    $('.scroll-bar').hide();
})


uilts.createScrollDom('.about-l-step', '.scroll-content', '.timer-ul'); // 创建  自定义滚动条
uilts.isFooterPosition(); // footer 浮动

// 接口业务

let newsController = {
    createNewsTab: function () {
        let bearingBox = $('.timer-ul');
        let tabDom = "";
        $.ajax({
            url: uilts.URL + 'news/list',
            dataType: 'json',
            data: '',
            type: 'GET',
            success: function (res) {
                let tabDateTime = {};
                $.each(res.data, function (index, el) {
                    tabDateTime = uilts.formatDateTime(el.releaseDate);
                    tabDom += ' <li data-newsId=' + el.id + '><p class="year">' + tabDateTime.year + '年</p><p class="year-describe">' + el.keyword + '</p></li>'
                })
                bearingBox.append(tabDom);
                return $('.timer-ul li').eq(0).click();
            },
            complete: function () { },
            error: function () { }
        })
    },
    createNewsTabContent(tabid) {
        let bearingBox = $('.about-r-article');
        bearingBox.empty();
        let contentDom = "";
        $.ajax({
            url: uilts.URL + 'news/content/' + tabid,
            dataType: 'json',
            type: 'GET',
            success: function (res) {
                let contentEl = res.data;
                let contentDateTime = uilts.formatDateTime(contentEl.releaseDate);
                contentDom += '<div class="head-line">' +
                    '<div class="date-icon-triangle">' +
                    '<span>' + contentDateTime.day + '</span><p>' + contentDateTime.year + '.' + contentDateTime.month +
                    '</p></div>' +
                    '<div class="head-line-content">' +
                    '<h6>' + contentEl.title + '</h6>' +
                    '<p>' + contentEl.keyword + '</p>' +
                    '</div>' +
                    '</div>' +
                    '<div class="article-content">' + contentEl.content + '</div>';
                bearingBox.append(contentDom);
            },
            complete: function () { },
            error: function () { }
        })

        return uilts.isFooterPosition(); // 再次检查高度 footer 是否浮动
    }
}

newsController.createNewsTab();